package handler;

public final class DeformationPoint implements Comparable<DeformationPoint>{
	
	public final double x,y;
	
	public DeformationPoint(double x, double y){
		this.x=x;
		this.y=y;
	}
	
	public DeformationPoint(double[] xs){
		this.x=xs[0];
		this.y=xs[1];
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("DeformationPoint [x=").append(x).append(", y=")
				.append(y).append("]");
		return builder.toString();
	}
	
	public double[] toArray(){
		return new double[]{x,y};
	}

	@Override
	public int compareTo(DeformationPoint p) {
		if(x < p.x ){
			return -1;
		} else if(x > p.x ){
			return 1;
		}
		if (y == p.y) {
			return 0;
		} else if(y < p.y ){
			return -1;
		} else if(y > p.y ){
			return 1;
		}
		
		return (int) Double.NaN;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof DeformationPoint) {
			DeformationPoint p = (DeformationPoint) obj;
			return compareTo(p) ==0;
		}
		return false;
	}
	
	
	
	


}
